<?php
namespace app\api\validate;

use think\Validate;

class User extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'nickname'                  => 'require',
        'mobile'                    => 'require|^1\d{10}$|unique:user',
//        'id_card'                   => 'require|^\d{17}[\dXx]$|unique:user',
        'title_id'                  => 'require',
        'group_ids'                 => 'require|array',
        'password'                  => 'regex:\S{6,30}',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'nickname.require'              => '姓名不能为空',
        'mobile.require'                => '手机号码不能为空',
        'mobile.^1\d{10}$'              => '手机号填写错误',
        'mobile.unique'                 => '手机号已被占用',
        'id_card.require'               => '身份证号码不能为空',
        'id_card.^\d{17}[\dXx]$'        => '身份证号码不正确',
        'id_card.unique'                => '身份证号已被占用',
        'title_id.require'              => '岗位职称不能为空',
        'group_ids.require'             => '用户角色不能为空',
        'group_ids.array'               => '角色数据格式不正确',
        'password.require'              => '登录密码不能为空',
        'password.regex'                => '密码长度 6-30 位',
    ];

    /**
     * 字段描述
     */
    protected $field = [

    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'edit' => ['nickname','mobile','id_card','title_id','group_ids','password'],
    ];

}
